Index: arithb.c
===================================================================
--- arithb.c	(revision 19414)
+++ arithb.c	(working copy)
@@ -2837,14 +2837,15 @@
 /* returns two euler calculation methods, so we can pick the best */
 static void mat3_to_eul2(float tmat[][3], float *eul1, float *eul2)
 {
-	float cy, quat[4], mat[3][3];
+	float cy, quat[4], mat[3][3], c, scale_vector[3];
+	int isLeftHandMatrix;
 	
-	Mat3ToQuat(tmat, quat);
-	QuatToMat3(quat, mat);
+	/*Mat3ToQuat(tmat, quat);
+	QuatToMat3(quat, mat);*/
 	Mat3CpyMat3(mat, tmat);
 	Mat3Ortho(mat);
 	
-	cy = (float)sqrt(mat[0][0]*mat[0][0] + mat[0][1]*mat[0][1]);
+	/*cy = (float)sqrt(mat[0][0]*mat[0][0] + mat[0][1]*mat[0][1]);
 	
 	if (cy > 16.0*FLT_EPSILON) {
 		
@@ -2862,7 +2863,30 @@
 		eul1[2] = 0.0f;
 		
 		VecCopyf(eul2, eul1);
+	}*/
+
+	Mat3ToSize(mat, scale_vector);
+	if (scale_vector[2] < 0.0){
+		isLeftHandMatrix = 1;
+	} else {
+		isLeftHandMatrix = 0;
 	}
+
+	eul1[1] = - (float)asin(mat[0][2]);
+	c = (float)cos(eul1[1]);
+	if (fabs(c) > 16.0*FLT_EPSILON) {
+		/*if LeftHand-Matrix with negativeZaxis = -Zscale factor*/
+		if (isLeftHandMatrix==1) {
+			eul1[0] = (float)atan2(mat[1][2]/c, -mat[2][2]/c);
+		} else {	/*if common-(RightHand)-Matrix*/
+			eul1[0] = (float)atan2(mat[1][2]/c, mat[2][2]/c);
+		}
+		eul1[2] = (float)atan2(mat[0][1]/c, mat[0][0]/c);
+	} else {
+		eul1[0] = 0.0f;
+		eul1[2] = - (float)atan2(mat[1][0], mat[1][1]);
+	}
+	VecCopyf(eul2, eul1);
 }
 
 void Mat3ToEul(float tmat[][3], float *eul)
@@ -3176,16 +3200,31 @@
 
 void Mat3ToSize( float mat[][3], float *size)
 {
+	float crossXY[3], threshold;
+
 	size[0]= VecLength(mat[0]);
 	size[1]= VecLength(mat[1]);
 	size[2]= VecLength(mat[2]);
+	/*migius: left-hand-detection
+	check, if uneven number of negative scale factors given*/
+	Crossf(crossXY, mat[0], mat[1]);
+	/*check signs, todo: searching for faster method*/
+	threshold = 0.0001f;
+	if( (crossXY[0] * mat[2][0]) < -threshold ||
+		(crossXY[1] * mat[2][1]) < -threshold ||
+		(crossXY[2] * mat[2][2]) < -threshold){
+		/*it is a Left-Hand-Matrix */
+		size[2]= -size[2];
+	}
+
 }
 
 void Mat4ToSize( float mat[][4], float *size)
 {
-	size[0]= VecLength(mat[0]);
-	size[1]= VecLength(mat[1]);
-	size[2]= VecLength(mat[2]);
+	/*migius:*/
+	float tmat[3][3];
+	Mat3CpyMat4(tmat, mat);
+	Mat3ToSize(tmat, size);
 }
 
 /* this gets the average scale of a matrix, only use when your scaling
